<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //Math.random随机数0-1不包括1
        var my = function (min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }
        console.log(my(1, 4));//1-4之间的随机整数包含1和4
        var arr = ['胡歌', '彭于晏', '赵玉真', '大大怪', '小小怪']
        console.log(arr[my(0, 4)]);//固定了 4
        console.log(arr[my(0,arr.length-1)]);//这个比较灵活arr.lenght-1

    </script>
</body>

</html>